{{include file="public/header" /}}

{{include file="public/header_top_nav" /}}

{{include file="public/home_search" /}}

<!--购物车页面 start -不需要body -->
<style>
    @media (max-width: 767px){
        .col-lg-12 {
            padding-left: 0!important;
        }
    }
    @media only screen and (max-width: 640px){
        .nav-left{width: 100% !important;}
        .nav-right{overflow: initial!important;width: 100% !important;}
        .cart-nav{background: none!important;height: auto!important;    padding-bottom: 10px!important;}
        .am-fr{float: none!important;}
        .cart-nav .separate-submit{height: 40px;width: 140px;    position: absolute;
            left: 175px;
            top: 50px;}
        .total-price-tips{margin-left:120px!important;}
    }
</style>
<div class="container mTop40">
    <div class="row hidden-xs">
        <div class="col-lg-12 text-center">
            <div class="inlineBlock carstep">
<!--                <img src="https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3754322468,1709809472&fm=26&gp=0.jpg" height="40" width="40">-->
                <i class="glyphicon glyphicon-shopping-cart cartIcon ftSize35"></i>
                <div class="margin10-0">
                    <div class="inlineFlex margin10-0 alignitemcenter text-left" >
                        <div class="cartHr"></div>
                        <i class=" glyphicon glyphicon-record fontSize16 ftColor256 mLeft10 mRight10"></i>
                        <div class="cartHr"></div>
                    </div>
                </div>
                <div class="ftSize16">Mi Carrito</div>
            </div>
            <div class="inlineBlock carstep">
                <i class="glyphicon glyphicon-pencil cartIcon ftSize35"></i>
                <div  class="margin10-0">
                    <div class="inlineFlex margin10-0 alignitemcenter" >
                        <div class="cartHr9A"></div>
                        <i class=" glyphicon  glyphicon-ok-circle fontSize16 ftColor9A mLeft10 mRight10"></i>
                        <div class="cartHr9A"></div>
                    </div>
                </div>
                <div class="ftSize16">Pedido Confirmado</div>
            </div>
            <div class="inlineBlock carstep">
                <i class="glyphicon glyphicon-list-alt cartIcon ftSize35"></i>
                <div class="margin10-0">
                    <div class="inlineFlex margin10-0 alignitemcenter">
                        <div class="cartHr9A"></div>
                        <i class=" glyphicon glyphicon-ok-circle fontSize16 ftColor9A mLeft10 mRight10"></i>
                        <div class="cartHr9A"></div>
                    </div>
                </div>
                <div class="ftSize16">Enviar Pedido</div>
            </div>
            <div class="inlineBlock carstep">
                <i class="glyphicon glyphicon-thumbs-up cartIcon ftSize35"></i>
                <div class="margin10-0">
                    <div class="inlineFlex margin10-0 alignitemcenter">
                        <div class="cartHr9A"></div>
                        <i class=" 	glyphicon glyphicon-ok-circle fontSize16 ftColor9A mLeft10 mRight10"></i>
                        <div class="cartHr9A"></div>
                    </div>
                </div>
                <div class="ftSize16">Pedido Completo</div>
            </div>
        </div>
    </div>
    <div class="row mTop50" id="goodsCarTab">
        <div class="col-lg-12 table-responsive">
            <table class="table am-table">
                <thead class="tableHead">
                <tr>
                    <th>Información Sobre Productos</th>
                    <th>Precio por Pieza</th>
                    <th>Cantidad</th>
                    <th>Total</th>
                    <th>Operaciones</th>
                </tr>
                </thead>
                <tbody>
                {{if empty($cart_list)}}
                <tr >
                    <td colspan="4" class="text-center">
                        <div class="mixed-tips">
                            <i class="am-icon-cart-plus am-fl icon"></i>
                            <div class="mixed-tips-content am-fl">
                                <h1>Su carrito de la compra sigue vacío，Puedes</h1>
                                <ul>
                                    <li>
                                        <span>Mira.</span>
                                        <a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/usergoodsfavor/index')}}{{/if}}" class="{{if empty($user)}}login-event{{/if}}">Mis favoritos</a>
                                    </li>
                                    <li>
                                        <span>Mira.</span>
                                        <a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/order/index')}}{{/if}}" class="{{if empty($user)}}login-event{{/if}}">Mi orden</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        </td>
                </tr>
                {{/if}}
                {{foreach $cart_list as $goods}}
                <tr id="data-list-{{$goods.id}}" data-id="{{$goods.id}}" data-goods-id="{{$goods.goods_id}}" class="{{if $goods['is_error'] eq 1}}am-danger{{/if}}">
                    <td class="pdLeft10">
                        <!-- 商品基础前面钩子 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_base_begin</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_base_begin';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品基础前面钩子 结束 -->

                        <label class="am-checkbox-inline am-success am-fl">
                            <input type="checkbox" value="{{$goods.id}}" {{if $goods['is_error'] eq 1}}disabled{{/if}} data-am-ucheck />
                        </label>
                        <div class="goods-detail">
                            <a href="{{$goods.goods_url}}" target="_blank">
                                <img src="{{$goods.images}}">
                            </a>
                            <div class="goods-base">
                                <a href="{{$goods.goods_url}}" target="_blank" class="goods-title">{{$goods.title}}</a>
                                {{if !empty($goods.spec)}}
                                <ul class="goods-attr">
                                    {{foreach $goods.spec as $spec}}
                                    <li>{{$spec.type}}：{{$spec.value}}</li>
                                    {{/foreach}}
                                </ul>
                                {{/if}}
                            </div>
                        </div>
                        <div class="wap-base am-show-sm-only">
                            {{if $goods['original_price'] gt 0}}
                            <span class="original-price">{{$currency_symbol}}{{$goods.original_price}}</span>
                            {{/if}}
                            <strong class="total-price-content">{{$currency_symbol}}{{$goods.price}}</strong>
                            <span class="wap-number">x{{$goods.stock}}</span>
                        </div>

                        <!-- 商品基础后面钩子 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_base_end</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_base_end';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品基础后面钩子 结束 -->
                    </td>
                    <td>
                        <!-- 商品单价前面钩子 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_price_begin</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_price_begin';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品单价前面钩子 结束 -->

                        <!-- 单价信息 -->
                        <div class="cart-price">
                            {{if $goods['original_price'] gt 0}}
                            <p class="original-price">{{$currency_symbol}}{{$goods.original_price}}</p>
                            {{/if}}
                            <p class="line-price">{{$currency_symbol}}{{$goods.price}}</p>
                        </div>

                        <!-- 商品单价后面钩子 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_price_end</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_price_end';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品单价后面钩子 结束 -->
                    </td>
                    <td>
                        <!-- 商品数量前面钩子 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_number_begin</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_number_begin';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品数量前面钩子 结束 -->

                        <!-- 数量操作 -->
                        {{if $goods['is_error'] eq 0}}
                        <div class="am-input-group am-input-group-sm stock-tag" data-inventory="{{$goods.inventory}}" data-price="{{$goods.price}}" data-ajax-url="{{:MyUrl('index/cart/stock')}}">
                            <span class="am-input-group-label {{if $goods['is_shelves'] eq 1 and $goods['is_delete_time'] eq 0}}stock-submit{{/if}}" data-type="min">-</span>
                            <input type="number" class="am-form-field" value="{{$goods.stock}}" {{if $goods['is_shelves'] neq 1 or $goods['is_delete_time'] neq 0}}disabled{{/if}} />
                            <span class="am-input-group-label {{if $goods['is_shelves'] eq 1 and $goods['is_delete_time'] eq 0}}stock-submit{{/if}}" data-type="add">+</span>
                        </div>
                        {{else /}}
                        <p class="invalid-stock">{{$goods.stock}}</p>
                        {{if !empty($goods['error_msg'])}}
                        <p class="am-text-danger am-margin-top-xs tips-error-text">{{$goods.error_msg}}</p>
                        {{/if}}
                        {{/if}}

                        <!-- 商品数量后面钩子 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_number_end</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_number_end';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品数量后面钩子 结束 -->
                    </td>
                    <td>
                        <!-- 商品总价面钩子 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_total_price_begin</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_total_price_begin';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品总价面钩子 结束 -->

                        <strong class="total-price-content">{{$currency_symbol}}{{$goods.total_price}}</strong>

                        <!-- 商品总价后面钩子 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_total_price_end</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_total_price_end';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品总价后面钩子 结束 -->
                    </td>
                    <td class="operation">
                        <a href="javascript:;" class="am-text-danger submit-delete" data-url="{{:MyUrl('index/cart/delete')}}" data-id="{{$goods.id}}" data-view="fun" data-value="ViewDeleteBack">Eliminar</a>

                        <!-- 商品操作栏 开始 -->
                        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                        <div class="plugins-tag">
                            <span>plugins_view_cart_operate</span>
                        </div>
                        {{/if}}
                        {{php}}
                        $hook_name = 'plugins_view_cart_operate';
                        $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$goods]);
                        if(!empty($hook_data) && is_array($hook_data))
                        {
                        foreach($hook_data as $hook)
                        {
                        if(is_string($hook) || is_int($hook))
                        {
                        echo htmlspecialchars_decode($hook);
                        }
                        }
                        }
                        {{/php}}
                        <!-- 商品操作栏 结束 -->
                    </td>
                </tr>
                {{/foreach}}
                </tbody>

            </table>
            <!-- 导航 -->
            <div class="cart-nav" style="background:#E6F6FF;">
                <div class="am-fl nav-left am-margin-left-xs">
                    <label class="am-checkbox-inline am-success select-all-event">
                        <input type="checkbox" value="1" data-am-ucheck />
                        <span class="el-text">Seleccionar</span>
                    </label>
                    <a href="javascript:;" class="am-margin-left-sm nav-delete-submit submit-ajax" data-url="{{:MyUrl('index/cart/delete')}}" data-id="0" data-view="reload" data-msg="¿No se puede restaurar, confirmar la operación después de borrar?">Eliminar</a>

                    <!-- 导航左侧内部 开始 -->
                    {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                    <div class="plugins-tag">
                        <span>plugins_view_cart_nav_left_inside</span>
                    </div>
                    {{/if}}
                    {{php}}
                    $hook_name = 'plugins_view_cart_nav_left_inside';
                    $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$cart_list]);
                    if(!empty($hook_data) && is_array($hook_data))
                    {
                    foreach($hook_data as $hook)
                    {
                    if(is_string($hook) || is_int($hook))
                    {
                    echo htmlspecialchars_decode($hook);
                    }
                    }
                    }
                    {{/php}}
                    <!-- 导航左侧内部 结束 -->
                </div>
                <div class="am-fr nav-right">
                    <!-- 导航右侧内部 开始 -->
                    {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
                    <div class="plugins-tag">
                        <span>plugins_view_cart_nav_right_inside</span>
                    </div>
                    {{/if}}
                    {{php}}
                    $hook_name = 'plugins_view_cart_nav_right_inside';
                    $hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$cart_list]);
                    if(!empty($hook_data) && is_array($hook_data))
                    {
                    foreach($hook_data as $hook)
                    {
                    if(is_string($hook) || is_int($hook))
                    {
                    echo htmlspecialchars_decode($hook);
                    }
                    }
                    }
                    {{/php}}
                    <!-- 导航右侧内部 结束 -->

                    <form action="{{:MyUrl('index/buy/index')}}" method="post" class="am-fr">
                        <span class="selected-tips am-fl"><span>Productos seleccionados</span> <strong>0</strong> <span>Caja</span></span>
                        <span class="total-price-tips am-fl">Total：</span>
                        <strong class="nav-total-price am-fl">{{$currency_symbol}}0.00</strong>
                        <input type="hidden" name="ids" value="0" />
                        <input type="hidden" name="buy_type" value="cart" />
                        <button type="submit" class="btn btn-primary mLeft40 separate-submit">Liquidación</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="{{$public_host}}static/web/js/modelCommon.js"></script>
<script type="text/javascript">

    $('.qty-btn').on('click', function (e) {
        var total = $("#totalPrice");
        var unit = $("#unitPrice").val()
        e.preventDefault();
        var $button = $(this);
        var oldValue = $button.parent().find('input').val();
        if ($button.hasClass('inc')) {
            var newVal = parseFloat(oldValue) + 1;
            total.val(unit * newVal)
        } else {
            // Don't allow decrementing below zero
            if (oldValue > 1) {
                var newVal = parseFloat(oldValue) - 1;
                total.val(unit * newVal)
            } else {
                newVal = 1;
                total.val(unit)
            }
        }
        $button.parent().find('input').val(newVal);
    });
    //全选
    $("#checkAll").click(function () {
        $("#goodsCarTab tbody tr").each(function () {
            $(this).find("input[type='checkbox']").prop('checked', true);
        });
        $("#goodsCarTab tfoot tr").find("input[type='checkbox']").prop('checked', true);
    });
    //全选-反选
    $("#goodsCarTab tfoot tr").find("input[type='checkbox']").click(function () {
        var checkeds = $(this).prop("checked");
        $("#goodsCarTab tbody tr").each(function () {
            $(this).find("input[type='checkbox']").prop('checked', checkeds);
        });
    });
    $("#delCarGoods").click(function () {
        var count = 0;
        $("#goodsCarTab tbody tr").each(function () {
            if ($(this).find("input[type='checkbox']").prop("checked")) {
                count++;
            }
        });
        if (count == 0) {
            showMsg("请选择需要删除的商品");
            return;
        }
        showConfirm("确认删除选中的商品吗？", function () {
            $("#goodsCarTab tbody tr").each(function () {
                if ($(this).find("input[type='checkbox']").prop("checked")) {
                    $(this).remove();
                }
            });
            if ($("#goodsCarTab tbody tr").length == 0) {
                $("#goodsCarTab tbody").append("<tr><td class='' colspan=5>空~</td></tr>")
            }
            //购物车后台逻辑
            alert("进行删除。。")
        });
    });
</script>

<!--购物车页面 end -不需要body -->

{{include file="public/footer_nav" /}}

{{include file="public/footer" /}}

<script type="text/javascript">
    // 返回处理
    function ViewDeleteBack(e) {
        if (e.code == 0) {
            $.AMUI.progress.done();
            Prompt(e.msg, 'success');
            $('#data-list-' + e.data_id).remove();
            HomeCartNumberTotalUpdate(parseInt(e.data));
        } else {
            $('form.form-validation').find('button[type="submit"]').button('reset');
            $.AMUI.progress.done();
            Prompt(e.msg);
        }
    }
</script>

<div id="com-alert" class="modal" style="z-index:9999;display: none;">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                <h5 class="modal-title"><i class="fa fa-exclamation-circle"></i> [Title]</h5>
            </div>
            <div class="modal-body small">
                <p>[Message]</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary ok" data-dismiss="modal">[BtnOk]</button>
                <button type="button" class="btn btn-default cancel" data-dismiss="modal">[BtnCancel]</button>
            </div>
        </div>
    </div>
</div>
